package com.infore.exchange.main.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.infore.common.base.EppPage;
import com.infore.common.base.Msg;
import com.infore.common.base.ResultUtil;
import com.infore.common.base.WrapperHelp;
import com.infore.common.fw.BaseController;
import com.infore.common.fw.CriterionRequest;
import com.infore.common.model.entity.exchange.TExTransformLog;
import com.infore.common.model.entity.vo.exchange.TExTransformLogVo;
import com.infore.common.request.query.exchange.TTransformInfoRequest;
import com.infore.common.request.query.exchange.TransformLogRequest;
import com.infore.common.response.ApiPageResponse;
import com.infore.exchange.main.service.TExTransformLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 数据交换日志 前端控制器
 * </p>
 *
 * @author lijh
 * @since 2023-02-21
 */
@RestController
@Api(value = "数据交换日志前端控制器", tags = "数据交换日志前端控制器")
@RequestMapping("/tExTransformLog")
public class TExTransformLogController extends BaseController {
	private String prefix = "/tExTransformLog";

	@Autowired
	private TExTransformLogService TExTransformLogService;

	@GetMapping()
	public String TExTransformLogController(){
		return prefix;
	}

	/**
	 * 查询数据交换日志列表
	 * @param textransformlogVo 数据交换日志的vo类
	 * @return Msg<Object> 结果集
	 * @author lijh
	 * @since 2023-02-21
	 */
	@PostMapping("/list")
	@ResponseBody
	@ApiOperation(value = "查询数据交换日志列表", notes = "数据交换日志列表查询 ")
	public Msg<Object> list(TExTransformLogVo textransformlogVo){
		//sql查询条件
		Wrapper<TExTransformLog> wrapper = null ;
		try {
			wrapper = (Wrapper<TExTransformLog>) WrapperHelp.addCondition(new EntityWrapper<TExTransformLog>(), textransformlogVo);
		} catch (Exception e) {
			e.printStackTrace();
			return ResultUtil.error(500,e.getMessage());
		}
		//查询方法
		Page<TExTransformLog> eppPage = new EppPage<TExTransformLog>(TExTransformLogService,textransformlogVo,wrapper);
		return ResultUtil.successPage(TExTransformLogService.selectPage(eppPage, wrapper));
	}


	@RequestMapping(value = "/query", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ApiOperation(value = "数据交换日志查询", notes = "数据交换日志查询")
	public ApiPageResponse<Map<String, Object>> queryTransformInfo(@ModelAttribute TransformLogRequest request) {
		startPage(request);
		List<Map<String, Object>> list = TExTransformLogService.queryTransformLog(request);
		return ApiPageResponse.ok(list,page.get());
	}
}
